﻿using pbvs.Models;
using pbvs.Models.DomainModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace pbvs.Services.ServiceExtensions
{
    public static class ContentServiceExtensions
    {
        public static ContentPageDomainModel ToDomainModel(this ContentPage value)
        {
            return new ContentPageDomainModel
            {
                Id = value.Id,
                MenuTitle = value.MenuTitle,
                Body = value.Body,
                Title = value.Title,
                Parent = value.Parent,
                HideFromMenu = value.HideFromMenu,
                PageName = value.PageName
            };
        }

        public static IEnumerable<ContentPageDomainModel> ToDomainModels(this IEnumerable<ContentPage> value)
        {
            return value.AsEnumerable().Select(n => n.ToDomainModel());
        }

        public static ContentPage ToEntity(this ContentPageDomainModel value)
        {
            return new ContentPage
            {
                Id = value.Id,
                MenuTitle = value.MenuTitle,
                Body = value.Body,
                Title = value.Title,
                Parent = value.Parent,
                HideFromMenu = value.HideFromMenu,
                PageName = value.PageName
            };
        }

        public static IEnumerable<ContentPage> ToEntities(this IEnumerable<ContentPageDomainModel> value)
        {
            return value.AsEnumerable().Select(n => n.ToEntity());
        }
    }
}